package com.pocket.insight.base.sql.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import org.apache.commons.lang3.BooleanUtils;

/**
 * 描述：
 *
 * @author shuize
 * @create 2024/12/14
 */
public class WithToTempContext {
    private static TransmittableThreadLocal<Boolean> doWithToTemp = new TransmittableThreadLocal();
    private static TransmittableThreadLocal<Boolean> doWithReuse = new TransmittableThreadLocal();

    public WithToTempContext() {
    }

    public static boolean isDoWithToTemp() {
        return BooleanUtils.isNotFalse((Boolean)doWithToTemp.get());
    }

    public static void setDoWithToTemp(Boolean doWithToTempIn) {
        doWithToTemp.set(doWithToTempIn);
    }

    public static boolean isDoWithReuse() {
        return BooleanUtils.isNotFalse((Boolean)doWithReuse.get());
    }

    public static void setDoWithReuse(Boolean doWithReuseIn) {
        doWithReuse.set(doWithReuseIn);
    }

    public static void remove() {
        doWithToTemp.remove();
        doWithReuse.remove();
    }
}
